<template>
<div id="echarts" style="width:100%;height:100%"></div>
</template>

<script>
import {getSite,selSevenDayDocBySite} from 'network/site.js'

let echarts = require('echarts/lib/echarts')
require('echarts/lib/chart/line')
// 以下的组件按需引入
require('echarts/lib/component/tooltip')   // tooltip组件
require('echarts/lib/component/title')   //  title组件
require('echarts/lib/component/legend')

let echart = function(docNum,docNum1) {
  var myChart = echarts.init(document.getElementById('echarts'));
  // 绘制图表
  myChart.setOption({
    legend: {
      data: ['本站点','所有站点']
    },
    xAxis: {
      type: 'category',   // 还有其他的type，可以去官网喵两眼哦
      name: '近1周单量',   // x轴名称
      // x轴名称样式
      nameTextStyle: {
        fontWeight: 600,
        fontSize: 18
      }
    },
    yAxis: {
      type: 'value',
      name: '/单',   // y轴名称
      // y轴名称样式
      nameTextStyle: {
        fontWeight: 600,
        fontSize: 18
      }
    },
    label: {},
    tooltip: {
      trigger: 'axis'   // axis   item   none三个值
    },
    series: [{
      name: '本站点',
      data: docNum,
      type: 'line'
    },{
      name: '所有站点',
      data: docNum1,
      type: 'line'
    }]
  });
}

export default {
  mounted(){
    selSevenDayDocBySite({siteName:JSON.parse(sessionStorage.loginAccount).sitetb.siteName}).then(res => {
      selSevenDayDocBySite({siteName:''}).then(res1 => {
        echart(res,res1)
      })
    })
  }
}
</script>

<style scoped>
</style>
